package cal

import (
	"idle/internal/game/attr"
	"idle/internal/game/hero"
)

// 伤害属性计算器
type DamageAttrCal struct {
}

func (d *DamageAttrCal) Cal(h *hero.Hero) {
	//基础伤害
	str := h.GetAttr(attr.Str)
	dex := h.GetAttr(attr.Dex)
	baseDamage := str/20 + dex/20
	h.SetAttr(attr.BaseDamage, baseDamage)

	extMinDamage := h.GetAttr(attr.ExtMinDamage)
	extMaxDamage := h.GetAttr(attr.ExtMaxDamage)
	extDamageRatio := h.GetAttr(attr.EnhanceDamage)
	extWeaponDamageRatio := h.GetAttr(attr.ExtWeaponDamageRatio)

	minDamage := (baseDamage + extMinDamage) *
		(100 + extDamageRatio + str*extWeaponDamageRatio/100) / 100

	maxDamage := (baseDamage + extMaxDamage) *
		(100 + extDamageRatio + str*extWeaponDamageRatio/100) / 100

	h.SetAttr(attr.MinDamage, minDamage)
	h.SetAttr(attr.MaxDamage, maxDamage)
}

func (d *DamageAttrCal) AssociatedAttr() []attr.Attribute {
	return []attr.Attribute{
		attr.Str,
		attr.Dex,
		attr.MinDamage,
		attr.MaxDamage,
		attr.ExtMinDamage,
		attr.ExtMaxDamage,
		attr.EnhanceDamage,
		attr.ExtWeaponDamageRatio,
	}
}
